package com.quasar.hpatient.utils;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.UUID;

public class AlarmTime implements Serializable {

    private Date date;

    public String getUuid() {
        return uuid;
    }

    public void setUuid(String uuid) {
        this.uuid = uuid;
    }

    private String uuid;
    public float unit;
    public String name;
    public String DataTime;
    public String getDataTime() {
        return DataTime;
    }

    public void setDataTime(String dataTime) {
        DataTime = dataTime;
    }



    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String id;

    public AlarmTime() {
        uuid = UUID.randomUUID().toString();
    }

    public Date getDate() {
        return date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

    public Calendar getCalendar() {
        if (date == null) {
            date = new Date();
        }
        Calendar result = Calendar.getInstance();
        Calendar old = Calendar.getInstance();
        old.setTime(date);
        result.set(Calendar.HOUR_OF_DAY, old.get(Calendar.HOUR_OF_DAY));
        result.set(Calendar.MINUTE, old.get(Calendar.MINUTE));
        result.set(Calendar.SECOND, 0);
        return result;
    }

    public void setTime(int hour, int minute) {
        Calendar result = Calendar.getInstance();
        result.set(Calendar.HOUR_OF_DAY, hour);
        result.set(Calendar.MINUTE, minute);
        result.set(Calendar.SECOND, 0);
        date = result.getTime();
    }
    public int getHour(){
        Calendar result = Calendar.getInstance();
        result.setTime(date);
        return  result.get(Calendar.HOUR_OF_DAY);
    }
    public int getMinute(){
        Calendar result = Calendar.getInstance();
        result.setTime(date);
        return  result.get(Calendar.MINUTE);
    }
    public String getTimeInfo() {
        String result = "";
        SimpleDateFormat format = new SimpleDateFormat("yyyy年MM月dd日 HH:mm:ss");
        result = format.format(getCalendar().getTime());
        return result;
    }
    public String getTime() {
        String result = "";
        SimpleDateFormat format = new SimpleDateFormat("HH:mm");
        result = format.format(getCalendar().getTime());
        return result;
    }
    @Override
    public int hashCode() {
        final int prime = 31;
        int result = 1;
        result = prime * result + ((uuid == null) ? 0 : uuid.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        AlarmTime other = (AlarmTime) obj;
        if (uuid == null) {
            if (other.uuid != null)
                return false;
        } else if (!uuid.equals(other.uuid))
            return false;
        return true;
    }

}
